﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MySSH.IBLL;
using MySSH.Domain.Entities;
using NHibernate.Criterion;

namespace MySSH.Web.Controllers
{
    public class ModuleController : Controller
    {
        public IBLLModule BLL { get; set; }
        //
        // GET: /Module/

        public ActionResult Index()
        {

            return this.Content(BLL.GetQueryByCriteria().List().Count.ToString());
        }
        //
        // GET: /Module/LoadUserInfo
        public ActionResult LoadUserInfo()
        {
            string resul = this.BLL.GetSysMenuByUser(0, "", "");
            return this.Content(resul);
        }

        public ActionResult GetList()
        {
            List<ICriterion> icList = new List<ICriterion>();
            int totalCount = 0;
            int limit = Convert.ToInt32(Request.Form["limit"]);
            int start = Convert.ToInt32(Request.Form["start"]);
            string sort = Request.Form["sort"];
            string dir = Request.Form["dir"];
            var list = this.BLL.GetListByPage(start, limit, sort, dir, out totalCount, icList).ToList();
            return this.Content(MySSH.Common.Helper.JSONHelper.ToJSON(list, totalCount));
          
        }
    }
}
